package day1109.observer;

import org.junit.Test;

import java.math.BigDecimal;

import static common.PrintUtil.printLine;

/**
 * @author Mr.ma
 * @since 2022/11/9 16:32
 * 拍卖开始
 **/
public class ObservePatternTest {
    @Test
    public void StartTest() {
        Auctioneer auctioneer = new Auctioneer();
        auctioneer.setName("张伟");
        Auctioneer auctioneer1 = new Auctioneer();
        auctioneer1.setName("曾小贤");
        BiddersEntity lv = new BiddersEntity("吕子乔", auctioneer);
        BiddersEntity da = new BiddersEntity("大师兄", auctioneer);
        BiddersEntity gu = new BiddersEntity("关谷神奇", auctioneer);
        new BiddersEntity("小黑",auctioneer);
        BiddersEntity lu = new BiddersEntity("陆展博", auctioneer1);
        BiddersEntity hu = new BiddersEntity("胡一菲", auctioneer1);
        BiddersEntity nuo = new BiddersEntity("诺澜", auctioneer1);
        BiddersEntity lisa = new BiddersEntity("丽萨", auctioneer1);
        printLine("上半场拍卖会");
        lv.auctioneer.setAuctionPrice(BigDecimal.valueOf(67.9));
        gu.auctioneer.setAuctionPrice(BigDecimal.valueOf(99.9));
        printLine("下半场拍卖会");
        hu.auctioneer.setAuctionPrice(BigDecimal.valueOf(7.9));
        lisa.auctioneer.setAuctionPrice(BigDecimal.valueOf(9.9));
    }

    @Test
    public void proxyTest(){
        Auctioneer ZwAuctioneer = new Auctioneer();
        AuctioneerProxy auctioneerProxy = new AuctioneerProxy(ZwAuctioneer);
        Auctioneer instance = (Auctioneer)auctioneerProxy.getInstance();
        ZwAuctioneer.setName("张伟");
        BiddersEntity lv = new BiddersEntity("吕子乔", ZwAuctioneer);
        BiddersEntity da = new BiddersEntity("大师兄", ZwAuctioneer);
        BiddersEntity gu = new BiddersEntity("关谷神奇", ZwAuctioneer);
        new BiddersEntity("小黑",ZwAuctioneer);
        instance.setAuctionPrice(BigDecimal.valueOf(67.9));
        lv.auctioneer.setAuctionPrice(BigDecimal.valueOf(98));
    }
}
